package chan.project.smartlawgateway.config;

import chan.project.smartlawmodel.enums.UserRoleEnum;
import cn.dev33.satoken.stp.StpInterface;
import cn.dev33.satoken.stp.StpUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 自定义权限验证接口扩展 
 */
@Slf4j
@Component
public class StpInterfaceImpl implements StpInterface {


    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        return null;
    }

    /**
     * 将当前登录用户的登录角色放入用户角色列表
     * @param loginId
     * @param loginType
     * @return
     */
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        String role = (String) StpUtil.getExtra("role");
        log.info("当前用户具有的权限role:{}",role);
        List<String> strings = new ArrayList<>();
        strings.add(role);
        return strings;
    }
}
